package optimizers.commons.evaluator;

public class ClusterSystem {
	private static ClusterNode[] clusterNodes;

	static {
		clusterNodes = new ClusterNode[] {
				new ClusterNode(new String[] { "java", "-jar",
						"C:\\Users\\Huy\\Documents\\AsProcessFitnessEvaluator.jar" })
				/*new ClusterNode(new String[] { "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a0", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a1", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a2", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a3", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a4", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a5", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a6", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" }),
				new ClusterNode(new String[] { "ssh", "huy@a7", "java", "-jar",
						"AsProcessFitnessEvaluator.jar" })*/
						};
	}

	public static ClusterNode getFirstFreeNode() {
		synchronized (clusterNodes) {
			for (int i = 0; i < clusterNodes.length; i++) {
				if (!clusterNodes[i].isBusy()) {
					clusterNodes[i].setBusy();
					return clusterNodes[i];
				}
			}
			return null;
		}
	}
}
